<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>爱音乐春季运动会</title>
		<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimal-ui">
		<link rel="stylesheet" href="./lib/jquery/jquery.mobile-1.4.5.min.css">
		<style>
			body{
				height: 100%;overflow: hidden;background-image: url(image/loading.png); background-size: 100% 100%;
			}
			.start-game{
				position: absolute;
				bottom: 10%;
				left: 50%;
				width: 35%;
				height: 7%;
				margin-left: -17%;
			}
			.rule{
				position: absolute;
				bottom: 1%;
				left: 3%;
				width: 20%;
				height: 7%;
			}
			.prize{
				position: absolute;
				bottom: 1%;
				right: 3%;
				width: 20%;
				height: 7%;
			}
			.role{
				position: absolute;
				left: 50%;
				top: 50%;
				margin-left: -89px;
				margin-top: -58px;
				width: 188px;height: 233px;
			}
		</style>
		<script src="./lib/jquery/jquery-1.9.1.min.js"></script>
		<script src="./lib/jquery/jquery.mobile-1.4.5.min.js"></script>
		<script src="tool/share.js"></script>
		<script src="tool/config.js"></script>
		<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_"+SITE_ID+"'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D"+SITE_ID+"' type='text/javascript'%3E%3C/script%3E"));</script>
		<script type="text/javascript">
			var _czc = _czc || [];
			_czc.push(["_setAccount", SITE_ID]);
			$("#cnzz_stat_icon_"+SITE_ID).css({display:"none"});
		</script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script type="text/javascript">

//			alert("location.href:"+location.href);
			var i = 0;
			setInterval(function(){
//				var sel = $("div.role img");
				var sel = $("div.role");
				sel[i%4].style.display = "";
				sel[(i+1)%4].style.display = "none";
				sel[(i+2)%4].style.display = "none";
				sel[(i+3)%4].style.display = "none";
				i++;
			},150);
			var init = false;
			function startGame(){
				if(!init){
					return;
				}
				_czc.push(["_trackEvent","首页","开始游戏","","",""]);
				window.location.href = "./index.html";
			}
			function showRule(){
				$("#myPopup").popup();
				$("#myPopup").popup('open');
				_czc.push(["_trackEvent","首页","查看规则","","",""]);
			}

			function closeView(){
                $("#myPopup").popup('close');
            }

			function goToLottery(){
				return;
				// if(!init){
				// 	return;
				// }
				// window.location.href = "./lucky.html";
			}

			$(function(){
				var jssdk = window.jssdk;
				wx.config({
					debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					appId: jssdk.appId, // 必填，公众号的唯一标识
					timestamp: jssdk.timestamp, // 必填，生成签名的时间戳
					nonceStr: jssdk.nonceStr, // 必填，生成签名的随机串
					signature: jssdk.signature,// 必填，签名，见附录1
					jsApiList: [
						'onMenuShareTimeline',
						'onMenuShareAppMessage',
						'onMenuShareQQ',
						'onMenuShareWeibo'
					] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
				});

				window["shareObj"] = {
                    linkstr:function(){
						var arr = window.location.href.split("/");
						arr[arr.length-1] = "startup.html";
						return arr.join("/");
					}(),
		            iconstr:function(){
						var arr = window.location.href.split("/");
						arr[arr.length-1] = "image/shareicon.png";
						return arr.join("/");
					}(),
                    decstr : '爱音乐给你献上100元三网话费',
                    title : '我参加了爱音乐春季运动会，拿到100元话费，数量有限，快来'
                };


				wx.ready(function() {
					wx.onMenuShareAppMessage({
						title: window["shareObj"].title,
						desc:  window["shareObj"].decstr,
						link:  window["shareObj"].linkstr,
						imgUrl:  window["shareObj"].iconstr,
						trigger: function (res) {
						},
						success: function (res) {
							alert('分享成功');
							// $("#sharebox").hide();
						},
						cancel: function (res) {
						},
						fail: function (res) {
						}
					});
					//分享到朋友圈
					wx.onMenuShareTimeline({
						title: window["shareObj"].title,
						link:  window["shareObj"].linkstr,
						imgUrl:  window["shareObj"].iconstr,
						trigger: function (res) {
						},
						success: function (res) {
							alert('分享成功');
							// $("#sharebox").hide();
						},
						cancel: function (res) {
						},
						fail: function (res) {
						}
					});
				});
				wx.error(function (res) {
					console.log(res.errMsg);
				});
			})

			gameInit();
			function gameInit(){
					$.ajax({
						url: AUTH_URL + '?gamesRedirectUri=' + encodeURIComponent(location.href.split('#')[0]) + '&datetime=' + new Date().getTime(),
						type: "POST",
						async: false,
						success: function (data) {
//							alert("auth:"+JSON.stringify(data));
							ret = data;
							console.log('location.href', location.href);
							if (data.result === 'error') {
								console.log('login error', data.errmsg);
							} else if (data.result === 'unauth') {
								console.log('login unauth', data.url);
								location.href = data.url;
							} else {
								console.log('logined', data);
								console.log('current wechat user', data.user);
								var user = data.user;
								myOpenId = user.openid;
								/*$$Client.headImgUrl = user.headimgurl;
								 username = user.nickname;*/
								window.localStorage.setItem("mz_jwt", data.mz_jwt);
								mz_jwt = data.mz_jwt;
								console.log(mz_jwt);
								$.ajaxSetup({
									beforeSend: function (xhr) {
										xhr.setRequestHeader("Authorization", "Bearer " + data.mz_jwt);
									}
								});
								$.ajax({
									url:API_ROOT+"init?debug="+API_DEBUG,
									dataType:"json",
									success:function(rs){
										if(!rs.success){
											alert("初始化失败");
											return;
										}else{
											$("#page")[0].style.display = "";
											init = true;
											window.localStorage.setItem("lotteryCount",rs.data.lotteryCount);
											window.localStorage.setItem("isSubscribed",rs.data.isSubscribed);
											window.localStorage.setItem("saveScoreApi",API_ROOT+"score");
										}
									},
									error:function(){
										alert("初始化失败");
									}
								});
							}
						},
						error: function () {
							alert("初始化失败");
						}
					});

			}
		</script>

	</head>
<body>
<img src="image/pointerup.png" style="position: fixed;left:91%;z-index: 999;width: 8%;display: none" id="pointerup">
<div data-role="page" id="page" style="display:none;background-image: url(image/homebg.png);background-repeat: no-repeat;background-size:cover">


	<div class="role" style="background-image: url('image/1.png');background-size: 100% 100%;margin-left: -116px;">
	</div>
	<div class="role" style="background-image: url('image/2.png');background-size: 100% 100%;margin-left: -112px;">

	</div>

	<div class="role" style="background-image: url('image/3.png');background-size: 100% 100%;width: 235px;height: 357px;margin-left: -152px;margin-top: -183px;">

	</div>

	<div class="role" style="background-image: url('image/4.png');background-size: 100% 100%;height: 302px;margin-top: -127px;">

	</div>
	<div class="start-game" onclick="startGame();">
	</div>
	<div class="rule" onclick="showRule();">
	</div>
	<div class="prize" onclick="goToLottery();">
	</div>
  	<div data-role="main" class="ui-content" style="bottom: 0;position: absolute;left: 2%;right: 2%;display: none">
		<div class="ui-grid-solo" onclick="startGame();" style="height: 50px;width: 150px;margin: 0 auto;">
		</div>
  		<!-- <div class="ui-grid-a" style="font-size: 26px;">
	      	<div class="ui-block-a" style="line-height: 45px;">
	        	<a href="#" data-rel="popup" data-position-to="window" style="color: #fff;font-weight:normal;display: none;">规 则</a>
	      	</div>

	      	<div class="ui-block-b" style="text-align: right;line-height: 45px;">
	        	<a href="./zsmember.html" style="color: #fff;font-weight:normal;display: none;">奖 品</a><br>
	      	</div>
	    </div> -->

    	<div data-role="popup" id="myPopup" data-overlay-theme="b" data-history="false" style="border-width: thick;border-radius: 34px;border-color: #e5b564;background-color: #ece7d0;word-wrap: break-word;padding: 10px;font-size: 15px;">
	      	<a href="#" style="padding: 0;position: absolute;top:6px;float: right;right: 13px;" onclick="closeView()"><img src="./image/close.png" style="width: 46px;"></a>
	      	<span style="display: inline-block;padding:2px;">
	      		<p style="text-align: center;color: red;font-size: 25px;line-height: 15px;">规则</p>
	      		<p>1、 参与方式：进入活动页面——参与游戏——抽奖——登记领奖人信息——活动结束后派奖</p>
				<p>2、活动奖品：100元三网话费、50元天翼话费、300M三网流量、60M天翼流量、2元天翼话费、院线通电影票10元抵用券、免费电信彩铃、爱音乐钻石会员（办理返10元优惠）</p>
				<p>3、抽奖机会：用户参与游戏后可以获得3次抽奖机会，赢取手机、流量话费等奖品。活动期间每人至多可以获得3次抽奖机会</p>
				<p>4、本活动最终解释权归天翼爱音乐所有</p>
	      	</span>
    	</div>
  	</div>
</div> 

</body>
</html>